home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / netprog.zip / NETPROG.TAR / fd.s5 / recvfile.c < prev    next >
C/C++ Source or Header  |  1989-12-17  |  424b  |  22 lines

  1. /*
  2.  * Receive a file descriptor from another process.
  3.  * Return the file descriptor if OK, otherwise return -1.
  4.  */
  5.  
  6. #include    <sys/types.h>
  7. #include    <stropts.h>
  8.  
  9. int
  10. recvfile(sfd)
  11. int    sfd;        /* stream pipe */
  12. {
  13.     int            fd;
  14.     struct strrecvfd    recv;
  15.  
  16.     if (ioctl(sfd, I_RECVFD, (char *) &recv) < 0)
  17.         return(-1);
  18.  
  19.     return(recv.fd);    /* return the new file descriptor */
  20.         /* we don't return the uid and gid that are available */
  21. }
  22.